package com.logic.saas.action.appmodules;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.interceptor.validation.SkipValidation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;

import com.logic.saas.action.BaseAction;
import com.logic.saas.pojo.SaasApplication;
import com.logic.saas.service.applicationmodules.AppModuleService;
import com.logic.saas.util.AddLog;


public class AppModules extends BaseAction {
	private static final long serialVersionUID = 8496859320118888426L;
	@Autowired
	private AppModuleService appModuleService;
	private List<SaasApplication> applications;
	
	@Action(value="applicationModules")
	@SkipValidation
    public String execute(){
    	AddLog.addToLog(this.getClass(), AddLog.INFO, "forward to application modules page.....");
    	String returnedStr = SUCCESS;
    	try {
			applications = appModuleService.findAllAppModules();
		}catch (DataAccessException e) {
			e.printStackTrace();
			this.addActionMessage(this.handelDataAccessException(e));
			this.addActionError(e.getMessage());
			returnedStr = ERROR;
		} catch (Exception e) {
			e.printStackTrace();
			this.addActionError(e.getMessage());
			returnedStr = ERROR;
		}
        return returnedStr;
    }

	public List<SaasApplication> getApplications() {
		return applications;
	}

	public void setApplications(List<SaasApplication> applications) {
		this.applications = applications;
	}
	
}
